<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增电子名片信息表')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-card-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">头像：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="bcUserImg">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="bcUserImg" name="file" type="file" >
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">手机号：</label>
                    <div class="col-sm-8">
                        <input name="bcUserPhone" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">公司地址：</label>
                    <div class="col-sm-8">
                        <input name="bcAddress" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">x坐标：</label>
                    <div class="col-sm-8">
                        <input name="bcXCoordinate" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">y坐标：</label>
                    <div class="col-sm-8">
                        <input name="bcYCoordinate" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">公司名称：</label>
                    <div class="col-sm-8">
                        <input name="bcName" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">职位：</label>
                    <div class="col-sm-8">
                        <input name="bcPosition" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input name="bcUserName" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">邮箱：</label>
                    <div class="col-sm-8">
                        <input name="bcMailbox" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">微信号：</label>
                    <div class="col-sm-8">
                        <input name="bcWxNumber" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">微信二维码：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="bcWxImg">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="bcWxImg" name="file" type="file" >
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">个人简介：</label>
                    <div class="col-sm-8">
                        <textarea name="bcBriefIntroduction" class="form-control"></textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">更多文件：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="bcFile">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="bcFile" name="file" type="file" multiple>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">图片展示：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="bcImgList">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="bcImgList" name="file" type="file" multiple>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户id：</label>
                    <div class="col-sm-8">
                        <input name="userId" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">公司id：</label>
                    <div class="col-sm-8">
                        <input name="pcId" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">插入时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="pcInsdate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">更新时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="pcUptime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态：</label>
                    <div class="col-sm-8">
                        <input name="pcStatus" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">录音信息：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="pcSpeech">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="pcSpeech" name="file" type="file" multiple>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">小程序码：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="pcProgramCode">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="pcProgramCode" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/card"
        $("#form-card-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-card-add').serialize());
            }
        }

        $("input[name='pcInsdate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='pcUptime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload', // 请替换为您的实际上传路径
            maxFileCount: 10, // 设置允许的最大文件数量
            multiple: true, // 允许选择多个文件
            autoReplace: true,
        }).on('fileuploaded', function (event, data, previewId, index) {
            console.log(data.response.url,'data.response.url')
            // $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            // 获取当前输入框的引用
            var $inputField = $("input[name='" + event.currentTarget.id + "']");

            // 获取当前输入框的值，如果不存在则初始化为空数组
            var currentUrls = $inputField.val() ? JSON.parse($inputField.val()) : [];

            // 将新的图片URL追加到现有URL数组中
            currentUrls.push(data.response.url);

            // 将更新后的URL数组转换为JSON字符串并存回输入框
            $inputField.val(JSON.stringify(currentUrls));
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>